<template>
  <div class="personalInfo common-details">
    <customDetailsTopbar title="个人信息" />
    <div class="d-scroll px-2 bg-white">
      <van-field v-model="info.userId" disabled label="账号" />
      <van-field v-model="info.userName" disabled label="用户名" />
      <van-field v-model="info.department" disabled label="所属单位" />
      <van-field v-model="info.roleName" disabled label="用户角色" />
    </div>
  </div>
</template>

<script>
import customDetailsTopbar from '@/components/globals/custom-details-topbar.vue'
import { getUserInfo } from '@/api/user'
export default {
  components: {
    customDetailsTopbar
  },
  data() {
    return {
      UserInfo: JSON.parse(sessionStorage.getItem('userInfo')),
      info: {
        userId: '',
        userName: '',
        department: '',
        roleName: ''
      }
    }
  },
  mounted() {
    this.getUserInfo()
  },
  methods: {
    async getUserInfo() {
      const userId = this.UserInfo.userId
      const { status, data } = await getUserInfo({ userId })
      if (status === 0 && data) {
        for (var i in this.info) {
          for (var j in data) {
            if (i === j) {
              this.info[i] = data[j]
            }
          }
        }
      }
    }
  }
}
</script>

<style lang="scss">

</style>
